#encoding=utf8
'''
Created on 2012-10-18

@author: Administrator
'''
from DbOperator import DbOperator
from Release import Release
from pub import Func
from pub.Config import Config
class ReleaseModel(DbOperator):
    '''
    classdocs
    '''


    def __init__(self):
        '''
        Constructor
        '''
        DbOperator.__init__(self)
    def getLastRelease(self):
        '''
        取得最后一条发行纪录
        '''
        aParam = {
                  Config.S_TABLE:Release.TABLE_NAME,
                  Config.S_SEARCHFIELDS:"*",
                  Config.S_SEARCHCONDITION:" 1=1 ",
                  Config.S_RESULTROW:1,
                  Config.S_ORDERBY:" %s DESC " %(Release.PRIMARY_KEY)
                  }
        result = self.getFieldByCondition(aParam)
        if(result != None):
            oRelease = Release()
            oRelease.set_created(result[Release.CREATED])
            oRelease.set_force_update(result[Release.FORCEUPDATE])
            oRelease.set_release_version(result[Release.RELEASEVERSION])
            oRelease.set_id(result[Release.PRIMARY_KEY])
            oRelease.set_release_log(result[Release.RELEASEVERSION])
            oRelease.set_releasetime(result[Release.RELEASETIME])
            oRelease.set_download_url(result[Release.DOWNLOADURL])
            return oRelease
        else:
            return None
if __name__=="__main__":
    oRelease = ReleaseModel()
    test = oRelease.getLastRelease()
    print test.get_id()
    print test.get_download_url()